<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Page extends Model {
	var $var;
	var $data;

    function Page()
    {
        // Call the Model constructor
        parent::Model();
    }
    
    function get()
    {
        $q = $this->db->get_where('pages', $this->var);
        if ($q -> num_rows() > 0) {
		foreach ($q -> result() as $row){
			$row->time = date( 'd.m.Y', strtotime($row->time) );
			$pg[] = $row;
		}
		return $pg;
	}
    }

    function insert_entry()
    {
	if(isset($this->data['time']) && preg_match('!([\d]+)\.([\d]+)\.([\d]+)!',$this->data['time'],$date) ){
		//$date  = explode(".",$this->data['time']);
		$this->data['time']  = date( 'Y-m-d H:i:s', mktime(0,0,0,$date[2],$date[1],$date[3]) );
	}else
		$this->data['time']  = date( 'Y-m-d H:i:s', time() );

        $this->db->insert('pages', $this->data);
    }

    function update_entry()
    {
	if(isset($this->data['time']) && preg_match('!([\d]+)\.([\d]+)\.([\d]+)!',$this->data['time'],$date) ){
		//$date  = explode(".",$this->data['time']);
		$this->data['time']  = date( 'Y-m-d H:i:s', mktime(0,0,0,$date[2],$date[1],$date[3]) );
	}else
		$this->data['time']  = date( 'Y-m-d H:i:s', time() );

	$this->db->where($this->var);
	$this->db->update('pages',  $this->data);
    }
    
    function remove_entry()
    {
    	$this->db->where($this->var);
        if( $this->db->delete('pages') )
        {
        	return TRUE;
        } else {
        	return FALSE;
        }
    }

}
/* End of file page.php */
/* Location: ./system/application/language/models/page.php */
